package com.touch.plugin;
import java.awt.*;
import java.awt.event.*;
/*
 * Copyright (c) 2009, TOD Productions All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 *	- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 *	- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 *	-Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */
/**
 * The ServerMenu functions as an easy-to-use GUI for the server.
 */
public final class PServerMenu extends PopupMenu implements ActionListener
{	
	//no idea but necessary
	private static final long serialVersionUID = 1L;	
	/**
	 * Constructs the ServerMenu. 
	 * There should only be one, however you can create a second menu and place it in other components so that you can control the Server somewhere else.
	 */
	public PServerMenu()
	{
		//object that displays the number of player's online.
		playersOnline	= new MenuItem("Players Online: 0");
		//button that closes the application
		exit			= new MenuItem("Shutdown");
		//Player-controlling commands
		pCommands		= new Menu("Player Commands");
		//Map-controlling commands
		mCommands		= new Menu("Map Commands");
		//Button that warps the player
		warpPlayer		= new MenuItem("Warp Player");
		//Button that jails a player
		jailPlayer		= new MenuItem("Jail Player");
		//Button that heals a player
		healPlayer		= new MenuItem("Heal Player");
		//Button that kills a player
		killPlayer		= new MenuItem("Kill Player");
		//Button that respawns a map
		respawnMap 		= new MenuItem("Respawn Map");
		//Gives EXP to a player
		giveExpToPlayer = new MenuItem("Give Exp To Player");
		//Button that mutes a player
		mutePlayer		= new MenuItem("Mute Player");
		//launches a map editor (needs environment setup)
		editMap			= new MenuItem("Edit Map");
		//executes a specific script
		script			= new MenuItem("Execute Script");
		
		//adds the action listener
		exit.addActionListener(this);		
		
		
		pCommands.add("Player Commands");
		pCommands.addSeparator();
		pCommands.add(giveExpToPlayer);
		pCommands.add(healPlayer);
		pCommands.add(jailPlayer);		
		pCommands.add(killPlayer);
		pCommands.add(mutePlayer);
		pCommands.add(warpPlayer);	
		
		mCommands.add("Map Commands");
		mCommands.addSeparator();
		mCommands.add(editMap);
		mCommands.add(respawnMap);
		
		this.add(playersOnline);
		this.addSeparator();
		this.add(mCommands);
		this.add(pCommands);
		this.addSeparator();
		this.add(script);
		this.add(exit);
	}
	private final MenuItem script;
	private final MenuItem mutePlayer;
	private final MenuItem editMap;
	private final MenuItem respawnMap;
	private final MenuItem giveExpToPlayer;
	private final MenuItem jailPlayer;
	private final MenuItem healPlayer;
	private final MenuItem killPlayer;
	private final MenuItem warpPlayer;
	private final Menu	 pCommands;
	private final Menu	 mCommands;
	private final MenuItem playersOnline;	
	private final MenuItem exit;
	
	/**
	 * Updates the displayed players online
	 * @param value value to display
	 */
	public final void updatePlayersOnline(int value)
	{
		playersOnline.setLabel("Players: " + value);
	}
		
	public final void actionPerformed(ActionEvent event) 
	{
		//if the source is the exit button
		if(event.getSource() == exit)
		{
			//shutdown.
			//Loader.shutdown();
		}		
	}
}

